$(function() {
	var currentUser = AV.User.current();
	var username = currentUser._serverData.username;
	var query = new AV.Query('gouwuche');
	query.equalTo('username', username);
	query.find().then(function(results1) {
			$("#shangpin").html("");
			var index = 0;
			var arrid = [];
			var nums = [];
			var length = results1.length;
			for(var i = 0; i < length; i++) {
				var que = new AV.Query('Product');
				que.equalTo('id', results1[i].attributes.id);
				arrid.push(results1[i].id);
				nums.push(results1[i].attributes.num);
				que.find().then(function(results) {
					var src = results[0].attributes.image.split(";");
					var price = results[0].attributes.price.split("¥");
					var str = '<div class="shangpin_longbo" data-id="' + results[0].attributes.id + '">';
					str += '<img src="' + src[0] + '"/>'
					$("#shangpin").append(str);
					index++;
					if(index == length) {
						$(".shangpin_longbo").click(function() {
							Todetail(this)
						});
					}
				}, function(error) {});
			}
		},
		function(error) {});

}());

function Todetail(t) {
	var id = t.getAttribute("data-id");
	console.log(id);
	location.href = "shangpinxiangqing_dj.html?id=" + id;
	console.log(111)
}